#include "editor/pencommand.hpp"

namespace nmc
{
    PenCommand::PenCommand(TileMap* tileMap, int x, int y, int tile, int tileFlags)
         :mTileMap(tileMap),
         mX(x),
         mY(y),
         mTile(tile),
         mTileFlags(tileFlags)
     {
        mOldTile = mTileMap->getTile(x, y);
        mOldTileFlags = mTileMap->getTileFlags(x, y);
     }

     void PenCommand::execute()
     {
         mTileMap->setTile(mX, mY, mTile);
         mTileMap->setTileFlags(mX, mY, mTileFlags);
     }

     void PenCommand::undo()
     {
         mTileMap->setTile(mX, mY, mOldTile);
         mTileMap->setTileFlags(mX, mY, mOldTileFlags);
     }
}